/**
 * 
 */
package com.ychs.corejava.lesson5;

/**
 * 给定年和月，输出这个月的天数
 * @author LENOVO
 * @version 1.0
 */
public class OutPutDays {
	/**
	 * 根据年和月，得到当月的天数
	 * @param year 年份
	 * @param month 月份
	 * @return 天数
	 */
	public int getDays(int year,int month) {
		int days = 30;
		switch (month) {
			case 1:
			case 3:
			case 5:
			case 7:
			case 8:
			case 10:
			case 12 :
				days = 31;
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				days = 30;
				break;
			case 2:
				LeapYear leapYear = new LeapYear();
				boolean flag = leapYear.isLeapYear(year);//调用判断闰年
				if (flag) {
					days = 29;
				}else {
					days = 28;
				}
				break;
		}
		return days;
	}

}
